Completed
Push — master ( 6b23d7...ea705b )
by
unknown
02:05
created

initAbeForProcesses.js ➔ init   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 41
rs 8.8571
nop 2

1 Function

Rating   Name   Duplication   Size   Complexity  
B initAbeForProcesses.js ➔ ... ➔ ??? 0 37 4
1
import debug from 'debug'
2
import extend from 'extend'
3
import moment from 'moment'
4
5
var Manager = require('../../cli').Manager
6
var Handlebars = require('../../cli').Handlebars
7
var config = require('../../cli').config
8
var abeExtend = require('../../cli').abeExtend
9
10
export var log
11
export var trace
12
export var error
13
export var processConfig
14
export var dateStart
15
16
export function getTime() {
17
	return (moment(moment() - dateStart).format('mm:ss')) + 'sec'
18
}
19
20
export function init(processName, conf) {
21
	var p = new Promise((resolve, reject) => {
0 ignored issues
show
Unused Code introduced by
The parameter reject is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
22
23
		log = debug(processName + ':log')
24
		log.color = 2
25
		trace = debug(processName + ':trace')
26
		error = debug(processName + ':error')
27
		error.color = 1
28
29
		processConfig = {}
30
		Array.prototype.forEach.call(process.argv, (item) => {
31
		  if (item.indexOf('=') > -1) {
32
		    var ar = item.split('=')
33
		    processConfig[ar[0]] = ar[1]
34
		  }
35
		})
36
		if(processConfig.ABE_WEBSITE) {
37
			config.set({root: processConfig.ABE_WEBSITE.replace(/\/$/, '') + '/'})
38
		}
39
40
		processConfig = extend(true, conf, processConfig)
41
42
		if(typeof processConfig.ABE_WEBSITE !== 'undefined' && processConfig.ABE_WEBSITE !== null) {
43
			abeExtend.hooks.instance.trigger('afterHandlebarsHelpers', Handlebars)
44
45
			Manager.instance.init()
46
	      .then(()=> {
47
	      	dateStart = moment()
48
	      	resolve()
49
	      })
50
	      .catch((e) => {
51
	        error('publish-all' + e)
52
	      })
53
		}else {
54
		  error('ABE_WEBSITE is not defined use node process.js ABE_WEBSITE=/pat/to/website')
55
		  process.exit(0)
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
56
		}
57
	})
58
59
	return p
60
}